package com.xjj.tree;

import com.xjj.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class E0094BinaryTreeInorderTraversal {

    List<Integer> result = new ArrayList<>();

    public List<Integer> inorderTraversal(TreeNode root) {
        traverse(root);
        return result;
    }

    private void traverse(TreeNode root) {
        if (root == null) {
            return;
        }
        traverse(root.left);
        result.add(root.val);
        traverse(root.right);
    }
}
